# -*- coding: utf-8 -*-
"""
Created on Wed Jul  7 18:22:19 2021

@author: lll
"""
import cv2
import os
import shutil #复制文件的库


# 全局变量，文件读取路径
read_path = "./JPEGImages/"
save_path = './out/'

files = os.listdir(read_path)
count = 5540
n = 0
for file_name in files:
    print(file_name)
    count = count + 1
    # img = cv2.imread(read_path + file_name)
    #height, width, channel = img.shape
    #resized_img = cv2.resize(img, (width//2, height//2))
    # cv2.imwrite(save_path + str(count) + '.jpg',img)

    # 设置旧文件名（就是路径+文件名）
    oldname = read_path + os.sep + files[n]  # os.sep添加系统分隔符

    # 设置新文件名（这里只给出例子，可自行修改）
    newname = save_path + os.sep + str(count) + '.jpg'
    # 用os模块中的rename方法就是将旧文件的文件名替换为新文件名
    os.rename(oldname, newname)
    n += 1

print("文件处理完毕")

